package com.general.framework.core.schema;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Setter;

/**
 * 公共的分页参数
 * @author leejean
 */
@Setter
@ApiModel("公共的分页参数")
public class PageRequest {

    /**
     * 默认页码
     */
    public static final int DEFAULT_PAGE = 1;

    /**
     * 默认每页数量
     */
    public static final int DEFAULT_SIZE = 10;

    public PageRequest() {

    }

    public PageRequest(int page, int size) {
        this.page = page;
        this.size = size;
    }

    @ApiModelProperty(value = "页码")
    private Integer page;

    @ApiModelProperty(value = "页大小")
    private Integer size;

    public Integer getPage() {
        return this.page == null || this.page < 1 ? DEFAULT_PAGE : this.page;
    }

    public Integer getSize() {
        return this.size == null ? DEFAULT_SIZE : this.size;
    }

    public PageRequest getPageRequest(){
        return this;
    }

}
